/**
 * ENGLISH DRY CAPCITY UNITS
 * Contains PINTS, QUARTS, PECKS, BUSHELS
 * METRIC BASE: LITERS
 * Each unit is set up as:
 * 
 * UNITS {
 * 
 * 	-- Returns value in same units --
 * 	public double toUnits(double value){
 * 		return value;
 * 	}
 * 
 * 	-- Returns value in other units --
 * 	-- One method for each type in category --
 * 	-- Example: UNITS = INCHES, value = 18, Convert toFeet, Return = 1.5 (Feet)
 * 	public double toOtherUnits(double value){
 * 		return value ( / or * ) ####;
 * 	}
 * 		
 * 	-- Converts value value of Unit type sourceUnit into UNITS type --
 * 	-- Example: UNITS = INCHES, value = 1.5, sourceUnit = FEET, return = 18 (Inches)
 * 	public double convert (double value, EnglishUnit sourceUnit){
 * 		return sourceUnit.toUnits(value);
 *	}
 * }
 */

package umuc.cmsc495.mach2.unit.english;

/**
 * @author Michael Swann
 */
public enum EnglishDryCapacityUnit {
    PINTS {
	@Override
	public double toPints(double value) {
	    return value;
	}

	@Override
	public double toQuarts(double value) {
	    return value / 2;
	}

	@Override
	public double toPecks(double value) {
	    return value / 16;
	}

	@Override
	public double toBushels(double value) {
	    return value / 64;
	}

	@Override
	public double toLiters(double value) {
	    return value / 1.8161659565;
	}

	@Override
	public double convert(double value, EnglishDryCapacityUnit sourceUnit) {
	    return sourceUnit.toPints(value);
	}
    },

    QUARTS {
	@Override
	public double toPints(double value) {
	    return value * 2;
	}

	@Override
	public double toQuarts(double value) {
	    return value;
	}

	@Override
	public double toPecks(double value) {
	    return value / 8;
	}

	@Override
	public double toBushels(double value) {
	    return value / 32;
	}

	@Override
	public double toLiters(double value) {
	    return value / 0.9080829782;
	}

	@Override
	public double convert(double value, EnglishDryCapacityUnit sourceUnit) {
	    return sourceUnit.toQuarts(value);
	}
    },

    PECKS {
	@Override
	public double toPints(double value) {
	    return value * 16;
	}

	@Override
	public double toQuarts(double value) {
	    return value * 8;
	}

	@Override
	public double toPecks(double value) {
	    return value;
	}

	@Override
	public double toBushels(double value) {
	    return value / 4;
	}

	@Override
	public double toLiters(double value) {
	    return value / 0.113510367;
	}

	@Override
	public double convert(double value, EnglishDryCapacityUnit sourceUnit) {
	    return sourceUnit.toPecks(value);
	}
    },

    BUSHELS {
	@Override
	public double toPints(double value) {
	    return value * 64;
	}

	@Override
	public double toQuarts(double value) {
	    return value * 32;
	}

	@Override
	public double toPecks(double value) {
	    return value * 4;
	}

	@Override
	public double toBushels(double value) {
	    return value;
	}

	@Override
	public double toLiters(double value) {
	    return value / 0.0283775930;
	}

	@Override
	public double convert(double value, EnglishDryCapacityUnit sourceUnit) {
	    return sourceUnit.toBushels(value);
	}
    };

    /**
     * @param sourceValve
     *            Value in Source Units
     * @param sourceUnit
     *            Source Unit Type
     * @return Value in Target Units
     */
    public abstract double toPints(double value);

    public abstract double toQuarts(double value);

    public abstract double toPecks(double value);

    public abstract double toBushels(double value);

    public abstract double toLiters(double value);

    public abstract double convert(double sourceValve, EnglishDryCapacityUnit sourceUnit);
}